package cn.edu.xust.controller;

import java.util.Arrays;
import java.util.Map;

import cn.edu.xust.util.PageUtils;
import cn.edu.xust.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.edu.xust.entity.GatewayEntity;
import cn.edu.xust.service.GatewayService;



/**
 *
 *
 * @author ufo
 * @email 2575829997@qq.com
 * @date 2024-03-27 18:09:23
 */
@RestController
@RequestMapping("xust/gateway")
public class GatewayController {
    @Autowired
    private GatewayService gatewayService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = gatewayService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		GatewayEntity gateway = gatewayService.getById(id);

        return R.ok().put("gateway", gateway);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody GatewayEntity gateway){
		gatewayService.save(gateway);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody GatewayEntity gateway){
		gatewayService.updateById(gateway);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		gatewayService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
